Variadic Templates for C++0x
نویسندگان
چکیده
Generic functions and classes typically accept a fixed number of type arguments. However, generic functions and classes that accept a variable number of type arguments have proven to be a very useful, even though there is no support for this feature in C++. Numerous foundational libraries rely on clever template and preprocessor tricks to emulate such variable-length templates. By several measures these emulations are inadequate. This paper describes variadic templates, an extension to the C++ language that significantly improves existing implementations of widely used C++ libraries in terms of code size, quality of error diagnostics, compilation speed, and generality. Furthermore, variadic templates enable new applications, such as type-safe implementations of functions like printf, and improved support for generic mixin classes. Variadic templates are part of the upcoming ISO C++ Standard, dubbed C++0x, and we have integrated variadic templates into the GNU C++ compiler.
منابع مشابه
Variadic Templates: Exploring the Design Space
The proposed resolution is to introduce a syntax and semantics for variable-length template argument lists (usable with function templates via explicit template argument specification and with class templates) along with a method of argument “packing” using the same mechanism to pass an arbitrary number of function call arguments to a function in a typesafe manner and “unpacking” to forward pac...
متن کاملProgramming GPUs with C++14 and Just-In-Time Compilation
Systems that comprise accelerators (e.g., GPUs) promise high performance, but their programming is still a challenge, mainly because of two reasons: 1) two distinct programming models have to be used within an application: one for the host CPU (e.g., C++), and one for the accelerator (e.g., OpenCL or CUDA); 2) using Just-In-Time (JIT) compilation and its optimization opportunities in both OpenC...
متن کاملHot-wire chemical vapor deposition for epitaxial silicon growth on large- grained polycrystalline silicon templates
We investigate low-temperature epitaxial growth of thin silicon films by HWCVD on Si w1 0 0x substrates and polycrystalline template layers formed by selective nucleation and solid phase epitaxy (SNSPE). We have grown 300-nm thick epitaxial layers at 300 8C on silicon w1 0 0x substrates using a high H :SiH ratio of 70:1. Transmission electron microscopy confirms that the 2 4 films are epitaxial...
متن کاملA Formalism for C++
In this paper, we develop a general formalism for describing the C++ programming language, and regular enough to cope with proposed extensions (such as concepts) for C++0x that affect its type system. Concepts are a mechanism for checking template arguments currently being developed to help cope with the massive use of templates in modern C++. The main challenges in developing a formalism for C...
متن کاملConcepts for C++0x
3 Design rationale 4 3.1 Template compilation model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.2 Specific language features in the design space . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3.2.1 Named conformance vs. structural conformance . . . . . . . . . . . . . . . . . . . . . . 6 3.2.2 New templates vs. new template parameters . . . . . . . . ....
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
- Journal of Object Technology
دوره 7 شماره
صفحات -
تاریخ انتشار 2008